#include <QCoreApplication>
#include <QHostAddress>
#include <QHostInfo>
#include <QNetworkInterface>
#include <QList>
#include <QDebug>
#include <QAbstractSocket>

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    qDebug() << "HostName: ";
    QString name = QHostInfo::localHostName();
    if (!QHostInfo::localDomainName().isEmpty())
        name += "." + QHostInfo::localDomainName();
    qDebug() << '\t' << name;

    QList<QHostAddress> addresses = QNetworkInterface::allAddresses();
    qDebug() << "IPv4: ";
    foreach (QHostAddress address, addresses) {
        if (address.protocol() == QAbstractSocket::IPv4Protocol
                && !address.isLoopback())
            qDebug() << '\t' << address.toString();
    }

    return a.exec();
}
